package com.tiancheng.trade.settlement.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Auther: liuzhonghu
 * @Date: 2024/4/3 16:00
 * @Param ${tags}
 * @Description:
 */
@Getter
@AllArgsConstructor
public enum ProductCostTypeEnum {

    FIXED("1", "固定金额"),
    PERCENTAGE("2", "百分比");

    private String code;
    private String desc;

    public static String getDesc(String code) {
        Optional<ProductCostTypeEnum> found = Arrays.stream(ProductCostTypeEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return "";
    }
}
